package cz.zcu.fav.ratdroid.bean;

import java.io.Serializable;

import org.joda.time.LocalDateTime;
import org.simpleframework.xml.Element;
import org.simpleframework.xml.Root;
import org.simpleframework.xml.convert.Convert;

import cz.zcu.fav.ratdroid.xml.PeriodConverter;
@Root(name="period")
@Convert(value = PeriodConverter.class)
public class Period implements Serializable
{
	public static String SINGLE_PERIOD_IDENTIFIER = "period.identifier";

	private static final long serialVersionUID = 5775387272164019484L;
	@Element(name = "id", required = false)
	private Integer id;
	@Element(name = "fromDate")
	// @Convert(value = LocalDateTimeConverter.class)
	private LocalDateTime fromDate;
	@Element(name = "toDate")
	// @Convert(value = LocalDateTimeConverter.class)
	private LocalDateTime toDate;
	@Element(name = "pickAction")
	private PickAction pickAction;
	@Element(name = "returnAction")
	private ReturnAction returnAction;
	@Element(name = "valid")
	boolean valid;

	Reservation reservation;

	public Integer getId()
	{
		return id;
	}

	public void setId(Integer id)
	{
		this.id = id;
	}

	public LocalDateTime getFromDate()
	{
		return fromDate;
	}

	public void setFromDate(LocalDateTime fromDate)
	{
		this.fromDate = fromDate;
	}

	public LocalDateTime getToDate()
	{
		return toDate;
	}

	public void setToDate(LocalDateTime toDate)
	{
		this.toDate = toDate;
	}

	public PickAction getPickAction()
	{
		return pickAction;
	}

	public void setPickAction(PickAction pickAction)
	{
		this.pickAction = pickAction;
	}

	public ReturnAction getReturnAction()
	{
		return returnAction;
	}

	public void setReturnAction(ReturnAction returnAction)
	{
		this.returnAction = returnAction;
	}

	public boolean isValid()
	{
		return valid;
	}

	public void setValid(boolean valid)
	{
		this.valid = valid;
	}

	public Reservation getReservation()
	{
		return reservation;
	}

	public void setReservation(Reservation reservation)
	{
		this.reservation = reservation;
	}

	@Override
	public int hashCode()
	{
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((fromDate == null) ? 0 : fromDate.hashCode());
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		result = prime * result
				+ ((pickAction == null) ? 0 : pickAction.hashCode());
		result = prime * result
				+ ((returnAction == null) ? 0 : returnAction.hashCode());
		result = prime * result + ((toDate == null) ? 0 : toDate.hashCode());
		result = prime * result + (valid ? 1231 : 1237);
		return result;
	}

	@Override
	public boolean equals(java.lang.Object obj)
	{
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Period other = (Period) obj;
		if (fromDate == null)
		{
			if (other.fromDate != null)
				return false;
		} else if (!fromDate.equals(other.fromDate))
			return false;
		if (id == null)
		{
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		if (pickAction != other.pickAction)
			return false;
		if (returnAction != other.returnAction)
			return false;
		if (toDate == null)
		{
			if (other.toDate != null)
				return false;
		} else if (!toDate.equals(other.toDate))
			return false;
		if (valid != other.valid)
			return false;
		return true;
	}
	
	
	
	
}
